package actions;

import javax.ejb.EJB;

import beans.UserManager;
import beans.UserManagerLocal;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import entities.User;

public class SaveUserAdminAction extends ActionSupport {
	
	@EJB
	private UserManagerLocal userMgr = new UserManager();
	private User user;
	
	public String execute(){
		if (ActionContext.getContext().getSession().get("userId") == null) {
			return "loginerror";
		}
		if (userMgr.updateUser(user)) {
			return "success";
		}
		else {
			this.addActionError("User update failed");
			return "error";
		}
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	
}
